package com.yuou.controller;

import javax.servlet.http.HttpServletRequest;

import org.apache.shiro.authz.AuthorizationException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

public class BaseExceptionController {
	/** 基于@ExceptionHandler异常处理 */
	   @ExceptionHandler
	   @ResponseBody
	   public String exp(HttpServletRequest request, Exception ex) throws Exception{
	      request.setAttribute("ex", ex);
	      // 根据不同错误转向不同页面  
	      if(ex instanceof AuthorizationException) {
	         //System.out.println("无权限异常处理");
	         return "201";
	      }
	      System.out.println("全局500错误");
	      return "500";
	   }
}
